import { http } from "@/utils/request"
import type { ICartList, ISkuIdList } from "@/types/cart"

/**
 * @description 加入购物车列表
 * @param skuId 
 * @param skuNum 
 * @returns 
 */
export const reqAddCart = (skuId: number, skuNum: number) => {
    return http(`/api/cart/addToCart/${skuId}/${skuNum}`, 'POST')
}

/**
 * @description 购物车列表数据
 * @returns 
 */
export const reqCartList = () => {
    return http<ICartList[]>(`/api/cart/cartList`, 'GET')
}

/**
 * @description 切换商品选中状态
 * @param skuID 商品ID
 * @param isChecked 商品选中状态 0代表取消选中 1代表选中
 * @returns 
 */
export const reqCheckCart = (skuID: number, isChecked: number) => {
    return http(`/api/cart/checkCart/${skuID}/${isChecked}`, 'GET')
}

/**
 * @description 商品全选
 * @param isChecked 
 * @param params 
 * @returns 
 */
export const reqBatchCheckCart = (isChecked: number, params: ISkuIdList) => {
    return http(`/api/cart/batchCheckCart/${isChecked}`, 'POST', params)
}

/**
 * @description 删除单个商品
 * @param skuId 
 * @returns 
 */
export const reqDeleteCart = (skuId: number) => {
    return http(`/api/cart/deleteCart/${skuId}`, 'DELETE')
}

/**
 * @description 批量删除商品
 * @param params 
 * @returns 
 */
export const reqBatchDeleteCart = (params: ISkuIdList) => {
    return http('/api/cart/batchDeleteCart', 'POST', params)
}